define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: '/addon/directmail',
        add_url: '/addon/directmail/create',
        edit_url: '/addon/directmail/edit',
        delete_url: '/addon/directmail/destroy',
    };


    return {

        index: function () {

            ea.table.render({
                init: init,
                toolbar: ['refresh', 'add', 'delete'],
                cols: [[
                    {field: 'id', minWidth: 80, title: '序号'},
                    {field: 'access_key', minWidth: 80, title: 'AccessKey'},
                    {field: 'access_secret', minWidth: 80, title: 'AccessSecret'},
                    {field: 'account_name', minWidth: 80, title: '发信地址'},
                    {field: 'region', minWidth: 80, title: '发信地域'},
                    {field: 'alias', minWidth: 80, title: '发信别名'},
                    {
                        field: 'is_default', minWidth: 80, title: '默认', templet: function (d) {
                            return d.is_default == 1 ? '<span style="color: red">是</span>' : '否';
                        }
                    },
                    {field: 'remark', minWidth: 80, title: '备注'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            'delete'
                        ]
                    }
                ]],
            });

            ea.listen();
        },
        create: function () {
            ea.listen();
        }, edit: function () {
            ea.listen();
        }, config: function () {
            ea.listen();
        }
    };
});
